package com.wei.news;

import android.content.Context;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreater;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreater;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.wei.base.BaseApplication;
import com.wei.news.dao.DaoSession;
import com.wei.news.db.DbManager;

import java.text.SimpleDateFormat;

/**
 * 作者：赵若位
 * 时间：2018/7/31 21:00
 * 邮箱：1070138445@qq.com
 * 功能：
 */
public class App extends BaseApplication
{
    public static DaoSession mSession;
    public static Context mContext;


    static
    {
        //设置全局的Header构建器
        SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater()
        {
            @Override
            public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout)
            {
                //全局设置主题颜色
                layout.setPrimaryColorsId(R.color.colorBG, R.color.colorEtHint);
                //指定为经典Header，默认是 贝塞尔雷达Header
                return new ClassicsHeader(context).setTimeFormat(new SimpleDateFormat());
            }
        });
        //设置全局的Footer构建器
        SmartRefreshLayout.setDefaultRefreshFooterCreater(new DefaultRefreshFooterCreater()
        {
            @Override
            public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout)
            {
                //指定为经典Footer，默认是 BallPulseFooter
                return new ClassicsFooter(context).setDrawableSize(20);
            }
        });
    }

    @Override
    public void onCreate()
    {
        super.onCreate();
        mSession = DbManager.getManager().initialization(getApplicationContext());
        mContext = getApplicationContext();
//        initLeakCanary();
    }


//    private void initLeakCanary()
//    {
//        if (LeakCanary.isInAnalyzerProcess(this))
//        {
//            return;
//        }
//        LeakCanary.install(this);
//    }
}
